package com.shiroexploit.task;

import com.shiroexploit.util.HttpRequest;
import com.shiroexploit.util.HttpRequestInfo;
import javafx.concurrent.Task;

import java.io.IOException;

public class TestConnectionTask extends Task<Integer> {

    private int status = 0;
    private HttpRequestInfo httpRequestInfo;

    public int getStatus(){
        return status;
    }

    public TestConnectionTask(HttpRequestInfo httpRequestInfo){
        this.httpRequestInfo = httpRequestInfo;
    }


    @Override
    protected Integer call() {
        try{
            HttpRequest.getResponse(httpRequestInfo);
        } catch (IOException e) {
            status = -1;
            return 1;
        }

        status = 1;
        return 1;
    }
}
